*** Settings ***
Documentation           通过cli获取内存的DeviceLocator
Resource                ../../test_function/cli/ssh.robot
Resource                ../../test_function/resource.robot
Suite Setup             Open SSH Connection
Suite Teardown          Close SSH Session    ${ssh}

*** Variables ***
${service}              bmc.kepler.compute
${path}                 /bmc/kepler/Systems/${SYSTEM_ID}/Memory/Memory_1_01010117
${interface}            bmc.kepler.Systems.Memory
${property}             DeviceLocator
${input}                ${BUSCTL_GET} ${service} ${path} ${interface} ${property}
${expected_output}      DIMM000

*** Test Cases ***
Get DeviceLocator Info Via cli
    [Documentation]    通过ssh查询内存的DeviceLocator信息
    [Tags]    Get_DeviceLocator_Info_Via_cli
    
    # 增加会话稳定性检查
    Wait Until Keyword Succeeds    3x    2s    Verify SSH Connection    ${ssh}
    
    # 增加命令执行重试机制
    ${rsp}=    Run Keyword And Ignore Error    
    ...    Wait Until Keyword Succeeds    3x    1s    
    ...    Execute SSH Command    ${ssh}    ${input}
    
    # 清理内容
    ${clean_rsp}=    Evaluate    re.sub(r'\\x1b\\[[0-9;]*[a-zA-Z]', '', """${rsp[1]}""")    modules=re
    ${clean_rsp}=    Evaluate    re.sub(r'Last login.*?\\n', '', \"\"\"${clean_rsp}\"\"\", flags=re.DOTALL)    modules=re
    
    Should Not Be Empty    ${clean_rsp}    msg=未获取内存的DeviceLocator信息
    Should Match Regexp    ${clean_rsp}    ${expected_output}       msg=未找到内存的DeviceLocator信息
